import dts from "rollup-plugin-dts";
import fs from "fs";

const files = fs
  .readdirSync("./src", {
    withFileTypes: true,
  })
  .filter((i) => i.isDirectory())
  .map((i) => ({
    file: `src/${i.name}/index.tsx`,
    name: i.name,
  }));

const modules = files.map((i) => ({
  input: `src/${i.name}/type.ts`,
  plugins: [dts()],
  // output: [{ file: `es/${i.name}/type.ts` }, { file: `types/${i.name}.ts` }],
  output: [{ file: `types/${i.name}.ts` }],
}));

export default [
  ...modules,
  {
    input: ["src/index.ts"],
    plugins: [dts()],
    output: [{ file: "types/index.d.ts" }],
  },
];
